function fnGetWareList(loadMore_) {
    if (loadMore_) {
        skip += LIMIT;
    } else {
        skip = 0;
    }
    var params = {
        fields: {},
        where: {
            supportAreaId: currentCity.id,
            wareTypeId: wareTypeList[api.pageParam.wareTypeIndex].id
        },
        skip: skip,
        limit: LIMIT
    }
    params = $api.jsonToStr(params);
    api.ajax({
        url: 'http://d.apicloud.com/mcm/api/ware?filter=' + params,
        method: 'get',
        headers: {
            "X-APICloud-AppId": "A6914327011091",
            "X-APICloud-AppKey": "8ac17d22e49cb7982d82796097cec52a6c7cd01d.1475375422841"
        }
    }, function(ret, err) {
        if (ret) {
            //console.log($api.jsonToStr(ret));
            api.refreshHeaderLoadDone();
            fnUpdateWareList(ret, loadMore_);
        } else {
            //alert(JSON.stringify(err));
        }
    });
}

function fnUpdateWareList(data_, loadMore_) {
    var list = $api.byId('list');
    // 1. 编译模板函数
    var tempFn = doT.template($api.byId('template').innerHTML);
    // 2. 多次使用模板函数
    var resultText = tempFn(data_);
    if (loadMore_) {
        $api.append(list, resultText);
    } else {
        $api.html(list, resultText);
    }//parseTapmode
    api.parseTapmode();
    if (loadMore_) {
        if (data_.length < LIMIT) {
            var pushStatus = $api.byId('pushStatus');
            pushStatus.innerHTML = "没有啦！";
        }
    }
}

function initEventListenter() {
    api.addEventListener({
        name: 'scrolltobottom',
        extra: {
            threshold: 300
        }
    }, function(ret, err) {
        fnGetWareList(true);
    });
    
}